A. Field of the Invention
The present invention relates to a method for controlling the speed of a step motor, especially to a method which can automatically adjust the speed of a step motor by providing an auto-detected delay parameter to a delay subroutine.
B. Description of the Prior Art
The step motor control involves in controlling the stepping motion of a step motor, especially the torque and the delay time for each step. The conventional step motor control can be either hardware-based or software-based. The hardware-based step motor control incorporates an integrated circuit in the machine for speed control. On the other hand, the software-based step motor control is implemented as a driver executable on a host computer.
The step motor control is very essential especially for a cooperated machine that demands high accuracy. For instance, in the application of a line image scanner which requires the original or the optical elements to be driven by the step motor, the speed of the step motor will determine the vertical resolution of the image. The stepping motion of the original must be carried out with accuracy if a faithful and complete representation of the original image is to be captured. Once the step motor is driven in nonuniform speed, the image will be distorted. To provide a smooth and uniform motion, the driver will call a delay subroutine for providing a proper delay time interval between two steps, so that each step will have enough time to generate sufficient torque for a subsequent step. If the delay time interval is too long or too short, the torque may be insufficient to drive a step of motor and cause a nonuniform acceleration in high speed.
Since the delay time interval determines the stability of the step motor, some driver developers use the fastest computer system model and CPU model as the standard reference value when testing the stability of the step motor. Others may use a CPU interrupt subroutine to generate a static delay time interval. For either approach, the delay parameter for the delay times of a conventional delay subroutine is always static regardless of the platform that is running the driver. The problems occur when the user runs the driver on a personal computer which has a different speed with the testing platform. For instance, if the driver is run by a CPU which is faster than the testing platform, then the step motor will skip steps or even halt. On the other hand, if the driver is run by a low speed CPU, then the speed of the step motor may be slowed down. The reason is that if the delay time interval is static, the machine cycle will be shorter, the number of delay times shall also be increased. However, the conventional approaches cannot automatically adjust the delay time interval in response to the actual speed of the CPU run by the platform. In the worst case, the step motor may produce nonuniform acceleration, or even halt.
Accordingly, it is an object of the present invention to provide a method for automatically adjusting the speed of a step motor by updating its delay parameter of a delay subroutine according to a system model and CPU model of the platform, thereby to keep the uniform acceleration and smooth movement of the step motor.
In accordance with the present invention, the present invention builds a lookup table for recording the currently available system model, CPU model, and corresponding delay times. Whenever the system is power-on, the step-motor driver will be enabled. The step-motor driver will automatically detect the computer system model and CPU model of the host computer. After finding the computer system model and CPU model, the proper corresponding delay times can be found by looking up the lookup table. The proper delay times found can be provided as the delay parameter for the delay subroutine of the driver. Consequently, the speed of the step motor can be well controlled according to the system model and CPU model of the computer that is actually running the driver.